local wen__zuqu = fk.CreateSkill {
  name = "wen__zuqu",
}

Fk:loadTranslationTable{
  ["wen__zuqu"] = "组曲",
  [":wen__zuqu"] = "出牌阶段开始时，你可以弃置一张牌并摸两张牌。若如此做，你于本阶段内不能连续使用颜色相同的牌。",
  ["#wen__zuqu-active"] = "组曲：弃置一张牌并摸两张牌，然后本阶段你不能连续使用同色牌",
  ["@wen__zuqu"] = "组曲",
}

wen__zuqu:addEffect(fk.EventPhaseStart, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(wen__zuqu.name) and player.phase == Player.Play
  end,

  on_use = function(self, event, target, player, data)
    local room = player.room
    local card = room:askToDiscard(player, {
        min_num = 1,
        max_num = 1,
        include_equip = true,
        skill_name = wen__zuqu.name,
        cancelable = false,
        skip = true,
      })

    if #card > 0 then
      room:throwCard(card, wen__zuqu.name, player, player)
    end

    if player.dead then return end
    player:drawCards(2, wen__zuqu.name)
  end,
})

wen__zuqu:addEffect(fk.CardUsing, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(wen__zuqu.name, true) and player.phase == Player.Play and player:usedSkillTimes("wen__zuqu", Player.CurrentPhase) > 0
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local color = data.card:getColorString(true)
    room:setPlayerMark(player, "@wen__zuqu", {color})
  end,
})

wen__zuqu:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    return table.contains(player:getTableMark("@wen__zuqu"), card:getColorString(true))
  end,
})

wen__zuqu:addEffect(fk.EventPhaseEnd, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(wen__zuqu.name)
    and data.phase == Player.Play
    and player:getMark("@wen__zuqu") ~= 0
  end,

  on_cost = Util.TrueFunc,

  on_use = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@wen__zuqu", 0)
  end,
})

return wen__zuqu